package com.jiangli.mapper;

import com.github.pagehelper.Page;
import com.jiangli.annotation.AutoFill;
import com.jiangli.dto.MerchantPageQueryDTO;
import com.jiangli.entity.Dish;
import com.jiangli.entity.Merchant;
import com.jiangli.enumeration.OperationType;
import com.jiangli.vo.MerchantVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MerchantMapper {


    @Select("SELECT COUNT(*) AS merchant_count FROM canteen_merchant;")
    Long getAllCount();


    List<Merchant> selectByIds(List<Long> ids);

    @Select("select * from canteen_merchant ")
    List<Merchant> selectAllMetadata();

    @Select("select  " +
            "merchant_name, status, location, business_meals_type, " +
            "merchant_rating, rating_count, image, " +
            "create_time, update_time,create_user " +
            "from canteen_merchant where id=#{id}")
    Merchant getByid(Long id);

    //更新商家信息
    @AutoFill(OperationType.UPDATE)
    void update(Merchant merchant);

    Page<Merchant> pageQuery(MerchantPageQueryDTO merchantPageQueryDTO);

    @AutoFill(OperationType.INSERT)
    void add(Merchant merchant);

    @Delete(" delete from canteen_merchant where id=#{merchantId} ")
    void delete(Long merchantId);

    @Select("select id,merchant_name,location,image,merchant_rating,rating_count from canteen_merchant")
    List<Merchant> selectALLMerchantMetadata();
}
